function FBinit(){

    FB.init({ 
        appId:'221957824499054', 
        cookie:true, 
        status:true, 
        xfbml:true 
    });
    FB.getLoginStatus(function(response) {
        var login = document.getElementById("login");
        if (!response.session) {
            // no user session available, someone you dont know
            login.style.display = "inline"; //show login button
                    
        } else {
            // logged in and connected user, someone you know
            FB.api('/me', function(user) {
                if(!session)$.post("/delo-war/ManageUserSessionServlet", {
                    user_id: response.session.uid,
                    access_token: response.session.access_token
                });
                if(user != null) {
                    var image = document.getElementById('image');
                    image.src = 'http://graph.facebook.com/' + user.id + '/picture';
                    var name = document.getElementById('name');
                    name.innerHTML = user.name;
                    var userinfo = document.getElementById('userinfo');
                    userinfo.style.display = "inline";
                }
            });
        }
    });
    FB.Event.subscribe('auth.login', function(response) {
        $.post("StoreUserServlet", {
            user_id: response.session.uid,
            access_token: response.session.access_token
        });
        $.post("/delo-war/ManageUserSessionServlet", {
            user_id: response.session.uid,
            access_token: response.session.access_token
        });
        window.location.reload();
    });
    FB.Event.subscribe('auth.logout', function(response) {
        $.post("/delo-war/ManageUserSessionServlet", {
            session : false
        });
        window.location.reload();
    });
    
}
//manage other events: http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/